package org.robby.hive.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
/**
 * 使用以下命令启动hive服务
 * [conkeyn@hadoop hive-0.12.0]$ ./bin/hive --service hiveserver
 */
public class HiveJdbcTest {

	public static void main(String[] args) throws Exception {
		Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
		Connection conn = DriverManager.getConnection("jdbc:hive://hadoop.main:10000/default");
		Statement stmt = conn.createStatement();
		ResultSet rs = stmt.executeQuery("select * from tab_cdr limit 10");
		while (rs.next()) {
			//System.out.println(rs.getString(1) + "\t" + rs.getString(2) + "\t" + rs.getString(3) + "\t" + rs.getString(4) + "\t"+ rs.getString(5) + "\t" + rs.getString(6));
		}

	}

}
